package com.xak.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @program: myspringboot
 * @description:
 * @author: 肖安康
 * @create: 2023-04-12 14:29
 **/
@Configuration
@EnableSwagger2//开启swagger注解驱动
public class SwaggerConfig {

        @Bean //把方法返回的数据对象 交于spring容器管理
        public Docket docket(){
            Docket docket = new Docket(DocumentationType.SWAGGER_2).groupName("一路向北")
                    .apiInfo(getInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.xak.controller")) //只为com.ykq.controller包下的类生成接口文档
                    .build();
            return docket;
        }

        private ApiInfo getInfo(){
            Contact DEFAULT_CONTACT = new Contact("小时不识月", "http://www.baidu.com", "120@qq.com");
            ApiInfo apiInfo=new ApiInfo("听歌测试API", "听歌测试API", "1.1.0", "http://www.jd.com",
                    DEFAULT_CONTACT, "南方姑娘", "http://www.aaa.com", new ArrayList<VendorExtension>());
            return apiInfo;
        }

}
